<template>
	<view class="content">
		<view class="row b-b">
			<text class="tit">姓名</text>
			<input class="input" type="text" v-model="personData.name" placeholder="请输入注册姓名" placeholder-class="placeholder" />
		</view>
		<view class="row b-b">
			<text class="tit">手机号</text>
			<input class="input" type="number" v-model="personData.contactPhone" placeholder="请输入联系号码" placeholder-class="placeholder" />
		</view>
		<button class="add-btn" @click="confirm">提交</button>
	</view>
</template>

<script>
	import {addPerson} from '@/api/logistics/postman'
	export default {
		data() {
			return {
				personData: {
					//快递员姓名
					name:'',
					//手机唯一标识
					phone:'',
					//快递员手机号码
					contactPhone:'',
				}
			}
		},
		onLoad(option){
			let title = '快递员注册';
			
			this.manageType = option.type;
			uni.setNavigationBarTitle({
				title
			})
		},
		methods: {
			/* switchChange(e){
				console.log(e)
				if(e.detail.value){
					this.addressData.defaultAddress = 1
				}else{
					this.addressData.defaultAddress = 0
				}
				console.info(this.addressData)
			},
			 */
			//地图选择地址
			/* chooseLocation(){
				uni.chooseLocation({
					success: (data)=> {
						
						console.log("获取的地址是=",data);
						console.info(data.name)
						this.addressData.detailedAddress=data.name+data.address
						this.addressData.address = data.name
						this.addressData.latitude = data.latitude;
						this.addressData.longitude = data.longitude;
						
						// this.addressData.phoneNumber = mobile
					}
				})
			},
			 */
			//提交
			confirm(){
				let data = this.personData
				let out =uni.getDeviceInfo()
				this.personData.phone = out.deviceId
				if(!data.name){
					this.$api.msg('请填写注册姓名');
					return;
				}
				if(!/(^1[3|4|5|7|8][0-9]{9}$)/.test(data.contactPhone)){
					this.$api.msg('请输入正确的手机号码');
					return;
				}
				addPerson(data).then(resp=>{
					if(resp.code === 200){
						this.$api.msg('注册信息提交成功请等待审核通过');
						setTimeout(()=>{
							uni.navigateBack()
						},2000)
					}
				})
				
			}, 
		}
	}
</script>

<style lang="scss">
	page{
		background: $page-color-base;
		padding-top: 16upx;
	}

	.row{
		display: flex;
		align-items: center;
		position: relative;
		padding:0 30upx;
		height: 110upx;
		background: #fff;
		
		.tit{
			flex-shrink: 0;
			width: 120upx;
			font-size: 30upx;
			color: $font-color-dark;
		}
		.input{
			flex: 1;
			font-size: 30upx;
			color: $font-color-dark;
		}
		.icon-shouhuodizhi{
			font-size: 36upx;
			color: $font-color-light;
		}
	}
	.default-row{
		margin-top: 16upx;
		.tit{
			flex: 1;
		}
		switch{
			transform: translateX(16upx) scale(.9);
		}
	}
	.add-btn{
		display: flex;
		align-items: center;
		justify-content: center;
		width: 690upx;
		height: 80upx;
		margin: 60upx auto;
		font-size: $font-lg;
		color: #fff;
		background-color: $base-color;
		border-radius: 10upx;
		box-shadow: 1px 2px 5px rgba(219, 63, 96, 0.4);
	}
</style>
